<template>
  <view @click="gotoPage()">
    <slot></slot>
  </view>
</template>

<script>
export default {
  name: "RouterLink",
  props: {
    url: {
      type: String,
      required: true,
    },
    mode: {
      validator(val) {
        return ["navigateTo", "switchTab", "reLaunch", "redirectTo"].includes(val);
      },
      default: "navigateTo",
    },
    params: {
      default() {
        return {};
      },
    },
  },
  methods: {
    gotoPage() {
      this.$Routers({
        url: this.url,
        type: this.mode,
        params: this.params,
      });
    },
  },
};
</script>

<style></style>
